< previous page page_396 next page >

Page 396
The BBProcess Routine
The BBProcess routine handles all the button actions initiated by the user and makes many calls to the other routines in the library. This routine is the high-level method of the class module; it is also the most involved routine in this library. It might look intimidating at first glance. But, after you inspect the first several lines, you see a pattern developing. More than half of the routine is devoted to handling the browse buttons (First, Back, Next, and Last). The rest is used to handle the add, edit, find, and delete operations. Enter Listing 10.19 into the library.
Type.gifListing 10.19. Coding the BBProcess routine.
Public Function BBProcess(frmTemp As Object, intBtn As Integer, strSearch As
arrow.gifString)
    '
    ' handle all button clicks
    '
    On Error GoTo LocalErr

    Dim lngResult As Long
    '
    Select Case intBtn
        Case 0 ' add/save/cancel
            Select Case frmTemp.cmdbtn(intBtn).Caption
                Case "&Save" ' save new
                    lngResult = RSWrite(frmTemp)
                    If lngResult = 0 Then
                        rs.Update
                    End If
                    If lngResult = 0 Then
                        lngResult = RSInit(frmTemp)
                    End If
                    If lngResult = 0 Then
                        lngResult = RSRead(frmTemp)
                    End If
                    If lngResult = 0 Then
                        lngResult = RSEnable(frmTemp, False)
                    End If
                    If lngResult = 0 Then
                        frmTemp.cmdbtn(0).Caption = "&Add"
                        frmTemp.cmdbtn(1).Caption = "&Edit"
                    End If
                Case "&Add" ' add new
                    rs.AddNew
                    lngResult = RSInit(frmTemp)
                    If lngResult = 0 Then
                        lngResult = RSEnable(frmTemp, True)
                    End If
                    If lngResult = 0 Then
                        frmTemp.cmdbtn(0).Caption = "&Save"
                        frmTemp.cmdbtn(1).Caption = "&Cancel"

 
< previous page page_396 next page >

If you like this book, buy it!